import React from "react";
import ReactDOM from 'react-dom';
import LinPinScreen from './views/linpin-screen/index.jsx';
import commonStore from './components/Common/store';
import { BrowserRouter as Router, Route, Link } from 'react-router-dom'
import dayjs from 'dayjs';
import * as Cesium from "cesium";
import locale from 'antd/es/date-picker/locale/zh_CN';
import { ThemeProvider } from 'styled-components';
import theme from './assets/theme';
import { ConfigProvider } from 'antd';
import zhCN from 'antd/locale/zh_CN';

import './assets/css/index.scss'
import store from '@/store'
import { Provider } from 'react-redux'

import { antdTheme } from '@/assets/theme/index.js'

class App extends React.Component {
  constructor(props) {
    super(props);
  }
  componentWillMount() {

  };
  render() {

    return (
      <ConfigProvider
        theme={{
          components: {
            ...antdTheme
          }
        }}
        locale={zhCN}
      >
        <Provider store={store}>
          < ThemeProvider theme={theme} >
            <Router>
              <LinPinScreen />
            </Router>
          </ThemeProvider >
        </Provider>
      </ConfigProvider >
    );
  }
}

const load = () => {
  window.antd = require("antd");
  window.antd.icons = require('@ant-design/icons');
  window.js = {};
  window.store = commonStore;
  window.dayjs = dayjs;
  window.locale = { zh: locale };
  window.Cesium = Cesium;
  ReactDOM.render(
    <App />,
    document.getElementById('app')
  );


  const debounce = (fn, delay) => {
    let timer = null;
    return function () {
      let context = this;
      let args = arguments;
      clearTimeout(timer);
      timer = setTimeout(function () {
        fn.apply(context, args);
      }, delay);
    }
  }
  const _ResizeObserver = window.ResizeObserver;
  window.ResizeObserver = class ResizeObserver extends _ResizeObserver {
    constructor(callback) {
      callback = debounce(callback, 16);
      super(callback);
    }
  }

}
load()